package com.example.module_web.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;
import com.example.module_web.R;
import com.example.module_web.beans.Order;
import java.util.HashMap;
import java.util.List;


/**
 * Created by Administrator on 2018/2/21.
 */

public class OrderAdapter extends FormAdapter<Order>{

    public OrderAdapter(Context context, List<Order> items) {
        super(context, items);
    }

    @Override
    protected int setItemLayoutId() {
        return R.layout.web_item_frag00_order;
    }


    @Override
    protected void onBindFormData(HashMap<String, View> holder, Object o) {
        Order order = (Order)o;
        ((TextView)holder.get(NUM)).setText(String.format("%s)", String.valueOf(order.getNumber())));
        ((TextView)holder.get(ACCOUNT)).setText(order.getAccount());
        ((TextView)holder.get(ADDRS)).setText(order.getAddress());
        ((TextView)holder.get(DATE)).setText(order.getDate());
        ((TextView)holder.get(PRODUCT)).setText(order.getProduct());
        ((TextView)holder.get(PAYABLEPRICE)).setText(String.valueOf(order.getPayablePrice()));
        ((TextView)holder.get(PAIDPRICE)).setText(String.valueOf(order.getPaidPrice()));
        ((TextView)holder.get(LABEL)).setText(order.getRemark());
    }

    @Override
    public HashMap<String,View> onBindItemViewId(HashMap<String, View> holder,View itemView) {
        holder.put(NUM,itemView.findViewById(R.id.item_form_num));
        holder.put(ACCOUNT,itemView.findViewById(R.id.item_form_account));
        holder.put(ADDRS,itemView.findViewById(R.id.item_form_addrs));
        holder.put(DATE,itemView.findViewById(R.id.item_form_date));
        holder.put(PRODUCT,itemView.findViewById(R.id.item_form_product));
        holder.put(PAYABLEPRICE,itemView.findViewById(R.id.item_form_payablePrice));
        holder.put(PAIDPRICE,itemView.findViewById(R.id.item_form_paidPrice));
        holder.put(LABEL,itemView.findViewById(R.id.item_form_label));
        return holder;
    }
}
